﻿

using Prism.Events;
using Prism.Services.Dialogs;
using System;
using System.Windows.Forms;

namespace TestDemo.ViewModels.Dialogs
{
    public class RedLineWorkDialogViewModel : BindableBase, IDialogAware
    {
        public string Title => "RedLine";

        public event Action<IDialogResult> RequestClose;
        private DelegateCommand keyEscCommand;
        public DelegateCommand KeyEscCommand =>
            keyEscCommand ?? (keyEscCommand = new DelegateCommand(ExecuteKeyEscCommand));
        private DelegateCommand keyF2Command;
        public DelegateCommand KeyF2Command =>
            keyF2Command ?? (keyF2Command = new DelegateCommand(ExecuteKeyF2Command));
        void ExecuteKeyF2Command()
        {
            DialogParameters param = new DialogParameters();
            param.Add("Act",1);
            RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel, param));
        }
        void ExecuteKeyEscCommand()
        {
            DialogParameters param = new DialogParameters();
            param.Add("Act", 0);
            RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel, param));
        }

        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
            
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
            
        }
    }
}
